Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sumbit method to enable the programmatic submission #1058

Merged
merged 1 commit into from
Oct 19, 2018

Conversation

sunweiye
Copy link
Contributor

Reasons for making this change

In some user case, the form should be submitted by the javascript program programmatically, for example, the submit button in the UI design is separated from the form.

Checklist

  • I'm updating documentation
    • I've checked the rendering of the Markdown text I've added
    • If I'm adding a new section, I've updated the Table of Content
  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
    • I've run npm run cs-format on my branch to conform my code to prettier coding style
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@glasserc glasserc merged commit f9c7031 into rjsf-team:master Oct 19, 2018
@glasserc
Copy link
Contributor

Refs #500. Thanks!

sbusch added a commit to sbusch/react-jsonschema-form that referenced this pull request Oct 26, 2018
…TML form

..., navigating away from current page at least in Firefox. Reason:
dispatched event was not cancelable, so preventDefault in onSubmit
couldn't cancel it.

Links:

* <https://stackoverflow.com/a/40916998>
* <https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelable>
glasserc pushed a commit that referenced this pull request Oct 26, 2018
…1066)

..., navigating away from current page at least in Firefox. Reason:
dispatched event was not cancelable, so preventDefault in onSubmit
couldn't cancel it.

Links:

* <https://stackoverflow.com/a/40916998>
* <https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelable>
althalus86 added a commit to althalus86/react-jsonschema-form that referenced this pull request Nov 3, 2018
epicfaace pushed a commit that referenced this pull request May 22, 2019
* react-dom is external peerDependency, just like react.

fixes version conflicts, e.g. I got an error

  Uncaught TypeError: this.updater.enqueueCallback is not a function when using setState callback

because I use React 16.x and react-jsonschema-form bundled react-dom 15.x

See facebook/react#10320 (comment)

* Fix for new submit() method (PR #1058) also submitting the HTML form

..., navigating away from current page at least in Firefox. Reason:
dispatched event was not cancelable, so preventDefault in onSubmit
couldn't cancel it.

Links:

* <https://stackoverflow.com/a/40916998>
* <https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelable>

* Synchronous call to onSubmit() from props

Due to the use of setImmediate() hack in setState utility function (utils.js),
onSubmit() handler from props is called asynchronously. This leads to massive
problems for operations requiring "trusted events", like window.open() or
programmatically submitting forms with target "_blank" (which we needed)

Because onSubmit() should not need the performance-related setImmiate() hack, I
replaced call to setState utility function with proper this.setState() from
React.

* fix failing FileWidget tests

by changing to proper use of setState() without setImmediate() hacks (see #1197)

* fix input type, fix test name

* Test with newer node versions

* Add node 12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants